#include "AwayMessageRequestTask.h"
#include "../packages/msg/CliSendIcbmCh2StatusMessageRequest.h"

namespace Impp
{

AwayMessageRequestTask::AwayMessageRequestTask(Oscar* oscar, Buddy* buddy, qword cookie) :
	Task(TASK_AWAY_MESSAGE_REQUEST,oscar,TASK_HANDLE_REQUESTID,cookie,10),buddy(buddy)
{
	wxLogTrace(wxT("AWAY"),wxT("AwayMessageRequestTask: new Task created"));
}

AwayMessageRequestTask::~AwayMessageRequestTask()
{
}


void AwayMessageRequestTask::userXOnlineXInfoReceived(bool hasAway){
	if(hasAway){
		wxLogTrace(wxT("AWAY"),wxT("AwayMessageRequestTask::userXOnlineXInfoReceived: Away succesfull received!"));
		oscar->getTaskManager()->deleteTask(this);
	}else{
		wxLogTrace(wxT("AWAY"),wxT("AwayMessageRequestTask::userXOnlineXInfoReceived: package had no away!"));
		//todo...
		//dword cookie = oscar->createCookie();
		//OscarServerCon*  bos = oscar->getBosConnection();
		//handleType = TASK_HANDLE_COOKIE;
		//handle = cookie;
		//bos->sendPackage(DATA, new CliSendIcbmCh2StatusMessageRequest(buddy,cookie,bos->nextRequestId()), PRIORITY_LOW, TASK_HANDLE_COOKIE, cookie);
	}
}

void AwayMessageRequestTask::srvClientIcbmSendxAck(){
	wxLogTrace(wxT("AWAY"),wxT("AwayMessageRequestTask::srcClientIcbm: Away succesfull received!"));
	oscar->getTaskManager()->deleteTask(this);
}


void AwayMessageRequestTask::timedOut(){
	wxLogTrace(wxT("AWAY"),wxT("AwayMessageRequestTask::timedOut: Task timed out!"));
}




Buddy* AwayMessageRequestTask::getBuddy(){
	return buddy;
}

}
